﻿using AutoMapper;
using Pay.Data;
using Pay.DTO;
using Pay.IService;

namespace Pay.Service.AutoMapper {

	public class TopicGroupMapper : IStartupDto {
		private IMapperConfigurationExpression _cfg;
		public TopicGroupMapper(IMapperConfigurationExpression cfg) {
			_cfg = cfg;
		}
		public void Execute() {
			Create();
		}
		protected virtual void Create() {

			_cfg.CreateMap<TopicGroup, topic_group_dto>()
				.ForMember(dest => dest.id, src => src.MapFrom(c => c.Id))
				.ForMember(dest => dest.topic_id, src => src.MapFrom(c => c.TopicId))
				.ForMember(dest => dest.show_images, src => src.MapFrom(c => c.ShowImages))
				.ForMember(dest => dest.topic_products, src => src.MapFrom(c => c.TopicProducts));

			_cfg.CreateMap<topic_group_dto, TopicGroup>()
			   .ForMember(dest => dest.Id, src => src.MapFrom(c => c.id))
			   .ForMember(dest => dest.TopicId, src => src.MapFrom(c => c.topic_id))
			   .ForMember(dest => dest.ShowImages, src => src.MapFrom(c => c.show_images))
               .ForMember(dest => dest.TopicProducts, src => src.MapFrom(c => c.topic_products));
		}
	}
}
